
<template>
    <div class="contentBox">
        <searchTop :isBottmNavigation="false"></searchTop>
        <banner :imglist="imglist"></banner>
        <div class="indexline"></div>
        <list :data="tableData"></list>
    </div>
</template>
  
<script lang="ts" setup>
import { ref, reactive } from "vue";
import { useRoute } from "vue-router";
import searchTop from "../../../components/searchTop.vue"; //搜索组件
import banner from "./banner.vue"
import list from "./list.vue"
import { getPlatformTypeProductStrict, ProductgetPlatFormTypeProductType, comgetAd } from "../../../utils/api"

const route = useRoute()
const platform_type_id = route.query.platform_type_id // 大分类ID

const tableData = ref([
    {
        name: '日用百货',
        id: 'id1',
        list: [{ id: 0 }]
    },
])


const imglist = ref([])
comgetAd({ type: 0, type_id: platform_type_id }).then(res => {
    console.log(res, '严选banner');
    imglist.value = res.data
})

const getData = (id: number, index: number, item: any) => {
    let paraams = { platform_type_id, category_id: id }
    getPlatformTypeProductStrict(paraams).then(res => {
        let str = { name: item.cate_name, id: 'id' + item.store_category_id, list: res.data.data }
        tableData.value.push(str)
    })
}

const getType = () => {
    tableData.value = []
    ProductgetPlatFormTypeProductType({ platform_type_id }).then(res => {
        res.data.forEach((item: any, index: number) => {
            getData(item.store_category_id, index, item)
        })
    })
}
getType()




// 列表

</script>
  
  
<style scoped>
.contentBox {
    max-width: 1920px;
    margin: 0 auto;
    background: #f5f5f5;
}

.indexline {
    width: 1920px;
    height: 30px;
    background: #F0AA77;
}
</style>
  